<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    let arr2 = [1, 2, 3, 4, 5]
    let arr1 = [
      {
        price: 100,
        count: 5,
        name: '手机'
      },
      {
        price: 200,
        count: 5,
        name: '电脑'
      },
      {
        price: 400,
        count: 5,
        name: '键盘'
      }
    ]
    // 定义一个函数 把所有项的单价*数量之和计算出来
    function getAllPrice(arr) {
      //  return arr.reduce((sum,item)=> {
      //    sum +=item.count*item.price
      //    return sum
      //   },0)
      return arr.reduce((sum,item)=>sum + item.count * item.price,0)

      // return arr.reduce((sum,item)=>sum+item,0)
    }
    const abc = getAllPrice(arr1)
    console.log(abc)

  </script>
</body>

</html>